
public class Main {

	static int level = 0;
	
	public static void main(String[] args) {
		Node root = buildTree();

		walkTree(root);
	}
	
	private static void walkTree(Node node) {
		level++;
		System.out.println(produceBlankString(level) + node.name);
		
		for (Node child : node.childs) {
			walkTree(child);
		}
		level--;
		
	}

	private static String produceBlankString(int len) {
		String blanks = "";
		for (int i = 0; i < len; i++) {
			blanks += "  ";
		}
		return blanks;
	}

	static Node buildTree() {
		Node accessories = new Node("accessories");
		Node hw = new Node("HW");
		Node sw = new Node("SW");
		Node root = new Node("root");
		Node disk = new Node("disk");
		link(accessories, hw);
		link(hw, root);
		link(disk, hw);
		link(sw, root);
		return root;
	}

	private static void link(Node child, Node parent) {
		child.parent = parent;
		parent.childs.add(child);
	}

}
